package com.ftg.learn.config;

import com.ftg.learn.interceptor.MyInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 布衣
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    MyInterceptor m;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(m)
                //静态资源放行
                .excludePathPatterns("/css/**", "/fonts/**", "/img/**", "/js/**")
                //放行swagger3相关
                .excludePathPatterns("/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs", "/v3/api-docs/**")
                //放行knife4j相关
                .excludePathPatterns("/doc.html", "/webjars/**", "/swagger-resources/**")
                //放行认证相关接口
                .excludePathPatterns("/authCenter/login", "/authCenter/captcha");
    }
}
